using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class DressScript : MonoBehaviour
{
    public Toggle[] toggles;//单选控件
    public Image[] backgrounds;//选中的金色圈圈
    int num = 0;//服装序号
    int temporaryNum = 0;
    public Image roleImg;
    
    // Start is called before the first frame update   ：：：
    void Start()
    {
        GetClothNum();
        toggles[num].isOn = true;
        roleImg.sprite = Resources.Load<Sprite>(VariableDocument.GetInstance.roleImgAdress[num]);
        backgrounds[num].color = new Color(1f, 1f, 1f, 1);
    }

    //点击toggle的响应事件
    public void OnToggleClick(int a)
    {
        for(int i = 0; i < 9; i++)
        {
            backgrounds[i].color = new Color(1f, 1f, 1f, 0);
        }
        temporaryNum = a;
        roleImg.sprite = Resources.Load<Sprite>(VariableDocument.GetInstance.roleImgAdress[a]);
        backgrounds[a].color = new Color(1f, 1f, 1f, 1);
    }
    //还原按钮
    public void Restore()
    {
        for (int i = 0; i < 9; i++)
        {
            backgrounds[i].color = new Color(1f, 1f, 1f, 0);
        }
        temporaryNum = num;
        toggles[num].isOn = true;
        roleImg.sprite = Resources.Load<Sprite>(VariableDocument.GetInstance.roleImgAdress[num]);
        backgrounds[num].color = new Color(1f, 1f, 1f, 1);
    }
    //保存按钮
    public void Save()
    {
        num = temporaryNum;
        SetClothNum();
    }
    

    private void GetClothNum()
    {
        num = VariableDocument.GetInstance.clothNum;
     
    }
    private void SetClothNum()
    {
        VariableDocument.GetInstance.clothNum = num;
    }
}
